package com.gitee.mango.api.vo;

import com.gitee.mango.api.enums.StatusEnum;
import lombok.Data;

import java.io.Serializable;

/**
 * @description 响应工具类
 * @author: breeze
 * @Date: 2024-07-29
 */
@Data
public class ResVo<T> implements Serializable {

    private static final long serialVersionUID = -510306209659393854L;

    private Status status;

    private T result;

    public ResVo() {
    }

    public ResVo(T t) {
        status = Status.newStatus(StatusEnum.SUCCESS);
        this.result = t;
    }
    public static <T> ResVo<T> ok(T t) {
        return new ResVo<>(t);
    }

    private static final String OK_DEFAULT_MESSAGE = "ok";
    public static ResVo<String> ok() {
        return ok(OK_DEFAULT_MESSAGE);
    }
}
